Page({
    data: {
        full_name: "",
        nick_name: "",
        sex: "",
        birthday: "",
        mobile: "",
        city: "",
        province: "",
        cid: "",
        pid: "",
        now: "",
        now2: "",
        name: ""
    },
    onLoad: function(e) {
        this.setData({
            full_name: e.full_name,
            nick_name: e.nick_name,
            sex: e.sex,
            birthday: e.birthday,
            mobile: e.mobile,
            city: e.city,
            province: e.province,
            cid: e.cid,
            pid: e.pid
        })
        console.log(e)
        console.log(
            e.full_name,
            e.nick_name,
            e.sex,
            e.birthday,
            e.mobile,
            e.city,
            e.province,
            e.cid,
            e.pid
        )
        console.log(
            this.data.full_name,
            this.data.nick_name,
            this.data.sex,
            this.data.birthday,
            this.data.mobile,
            this.data.city,
            this.data.province,
            this.data.cid,
            this.data.pid
        )
        if (e.now == "nick_name") {
            this.setData({
                name: "昵称",
                now: e.nick_name,
                now2: "nick_name",
            })
        } else if (e.now == "full_name") {
            this.setData({
                name: "真实姓名",
                now: e.full_name,
                now2: "full_name",
            })
        }else if (e.now == "mobile") {
            this.setData({
                name: "手机号",
                now: e.mobile,
                now2: "mobile",
            })
        }
    },
    sure_FN: function(e) {
        if(this.data.now==""){            
            wx.showModal({
                "title":"提示",
                "content":"请填写信息",
                "mask":true,
                "showCancel":false
            })
            return;
        }
        console.log(
            this.data.full_name,
            this.data.nick_name,
            this.data.sex,
            this.data.birthday,
            this.data.mobile,
            this.data.city,
            this.data.province,
            this.data.cid,
            this.data.pid
        )
        console.log(1)
        var self = this;
        var json = {
            user_id: wx.getStorageSync("user_id"),
            full_name: self.data.full_name,
            nick_name: self.data.nick_name,
            sex: self.data.sex,
            birthday: self.data.birthday,
            mobile: self.data.mobile,
            city: self.data.city,
            province: self.data.province,
            cid: self.data.cid,
            pid: self.data.pid
        };
        console.log(self.data.now2)
        json[self.data.now2] = self.data.now;
        console.log(json)
        wx.request({
            url: "https://wx.ichelaba.com/htapi/index.php/user/user/saveInfo",
            data: json,
            method: "GET",
            success: function(res) {
                console.log(res);
                if (res.data.result) {
                    wx.showToast({
                        "title": "修改成功",
                        "complete": function() {
                            wx.reLaunch({
                                url: "/pages/infm/infm"
                            })
                        }
                    })
                }
            }
        })
    },
    clean_FN: function() {
        this.setData({
            now: ""
        })
    },
    xiugai_FN:function(e) {
        this.data.now = e.detail.value;
    },
    bindPickerChange1:function(e){
      console.log(e);
      // this.setData({
      //   birthday:e.v
      // })
    }
})